package com.jpdr.wificommdev.classes;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jpdr.wificommdev.MenuActivity;
import com.jpdr.wificommdev.R;

public class ContactsAdapter extends BaseAdapter {

	
	String [] mContacts;
	String [] mPhones;
    Context mContext;
    int mIcon;
    private static LayoutInflater mInflater=null;

    public ContactsAdapter(MenuActivity menuActivity, String[] pContacts, String[] pPhones, int pIcon) {
    	
    	mContacts = pContacts;
    	mPhones = pPhones;
        mContext=menuActivity;
        mIcon=pIcon;
        mInflater = ( LayoutInflater )mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        
    }
    
    
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mContacts.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;

	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		
		Holder holder=new Holder();
		View rowView;       
        rowView = mInflater.inflate(R.layout.layout_menu_list_item, null);
        holder.imageView_Icon=(ImageView) rowView.findViewById(R.id.menu_list_item_icon);
        holder.textView_Line1=(TextView) rowView.findViewById(R.id.menu_list_item_textview_line1);
        holder.textView_Line2=(TextView) rowView.findViewById(R.id.menu_list_item_textview_line2);
        
        holder.imageView_Icon.setImageResource(mIcon);
		holder.textView_Line1.setText(mContacts[position]);
		holder.textView_Line2.setText(mPhones[position]);
         
		rowView.setOnClickListener( new OnClickListener()
		{
			@Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
          //      Toast.makeText(context, "You Clicked "+result[position], Toast.LENGTH_LONG).show();
            }

			
			
		}
		
		);
		
		return rowView;
		
		
	}
	
	public class Holder
    {
		ImageView imageView_Icon;
		TextView textView_Line1;
        TextView textView_Line2;
        
    }


}
